package com.gxa.service.impl;

import com.gxa.common.JsonResult;
import com.gxa.common.R;
import com.gxa.mapper.WorksheetMapper;
import com.gxa.pojo.Worksheet;
import com.gxa.service.WorksheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

@Service
public class WorkSheetServiceImpl implements WorksheetService {
    @Autowired
    private WorksheetMapper worksheetMapper;
    @Override
    public R addWorkSheet(Worksheet worksheet) {
        R r=new R();
        worksheetMapper.addWorkSheet(worksheet);
        r.setCode(200);
        r.setMsg("添加成功");
        return r;
    }

    @Override
    public JsonResult queryWorkSheetList(Integer repair_id) {
        JsonResult jsonResult=new JsonResult();
        List<Worksheet> worksheets=worksheetMapper.queryWorkSheetList(repair_id);
        jsonResult.setCode(200);
        jsonResult.setMsg("查询成功");
        jsonResult.setData(worksheets);
        return jsonResult;
    }

    @Override
    public R deleteWorkSheet(Integer worksheetid) {
        R r=new R();
        worksheetMapper.deleteWorkSheet(worksheetid);
        r.setCode(200);
        r.setMsg("删除成功");
        return r;
    }

    @Override
    public R updateWorkSheet(Worksheet worksheet) {
        R r=new R();
        worksheet.setState_feedback(1);
        worksheetMapper.updateWorkSheet(worksheet);
        r.setCode(200);
        r.setMsg("更新成功");
        return r;
    }
}
